/**************************************************************************
 * Name         : pvrvdastream.h
 * Title        : PowerVR VDA Command Stream 
 * Author       : Jason Rogers
 * Created      : 20/12/04
 *
 * Copyright    : 2004 by Imagination Technologies. All rights reserved.
 *              : No part of this software, either material or conceptual 
 *              : may be copied or distributed, transmitted, transcribed,
 *              : stored in a retrieval system or translated into any 
 *              : human or computer language in any form by any means,
 *              : electronic, mechanical, manual or other-wise, or 
 *              : disclosed to third parties without the express written
 *              : permission of VideoLogic Limited, Unit 8, HomePark
 *              : Industrial Estate, King's Langley, Hertfordshire,
 *              : WD4 8LZ, U.K.
 *
 * Description  : PowerVR Video Decode Accelerator API - MVDA2 Command Stream defines
 *
 * Platform     : 
 *

 Version	 	: $Revision: 1.3 $

 Modifications	:

 $Log: PVRVDAStream.h,v $

  --- Revision Logs Removed --- 

  --- Revision Logs Removed --- 

  --- Revision Logs Removed --- 


 */

#ifndef _PVR_VDA_COMMAND_STREAM_H_
#define _PVR_VDA_COMMAND_STREAM_H_

/* Commands */
#define PVRVDA_CMD_MC_OPP_TYPE					(0x00000000)
#define PVRVDA_CMD_PRED_TARGET					(0x08000000)
#define PVRVDA_CMD_ADD_RESIDUAL					(0x10000000)
#define PVRVDA_CMD_IMAGE_WRITE					(0x18000000)
#define PVRVDA_CMD_FETCH_PRED					(0x80000000)
#define PVRVDA_CMD_BUFFER_SELECT				(0x20000000)
#define PVRVDA_CMD_INTRA_OP_TYPE				(0x28000000)
#define PVRVDA_CMD_INTRA_PRED					(0x30000000)
#define PVRVDA_CMD_DECODE_SYNC					(0x78000000)
#define PVRVDA_CMD_PROCESS_H264_RES				(0x40000000)

#define PVRVDA_CMD_MASK							(0xf8000000)


/* Buffer Select command */
#define PVRVDA_BUF_SEL_REFA_MASK				(0x0000000f)
#define PVRVDA_BUF_SEL_REFB_MASK				(0x000000f0)
#define PVRVDA_BUF_SEL_OUTPUT_MASK				(0x00000f00)
#define PVRVDA_BUF_SEL_REFA_SHIFT				(0)
#define PVRVDA_BUF_SEL_REFB_SHIFT				(4)
#define PVRVDA_BUF_SEL_OUTPUT_SHIFT				(8)

/* Motion Comp Operation Type */
#define PVRVDA_MC_TYPE_COL_PLANE_MASK			(0x00000003)
#define PVRVDA_MC_TYPE_COL_PLANE_Y				(0x00000000)
#define PVRVDA_MC_TYPE_COL_PLANE_U				(0x00000001)
#define PVRVDA_MC_TYPE_COL_PLANE_V				(0x00000002)
#define PVRVDA_MC_TYPE_BLK_WIDTH_MASK			(0x0000000c)
#define PVRVDA_MC_TYPE_BLK_WIDTH_4				(0x00000000)
#define PVRVDA_MC_TYPE_BLK_WIDTH_8				(0x00000004)
#define PVRVDA_MC_TYPE_BLK_WIDTH_16				(0x00000008)
#define PVRVDA_MC_TYPE_BLK_WIDTH_2				(0x0000000c)
#define PVRVDA_MC_TYPE_BLK_HGHT_MASK			(0x00000030)
#define PVRVDA_MC_TYPE_BLK_HGHT_4				(0x00000000)
#define PVRVDA_MC_TYPE_BLK_HGHT_8				(0x00000010)
#define PVRVDA_MC_TYPE_BLK_HGHT_16				(0x00000020)
#define PVRVDA_MC_TYPE_BLK_HGHT_2				(0x00000030)
#define PVRVDA_MC_TYPE_INTR_RND_MODE			(0x00000040)
#define PVRVDA_MC_TYPE_AVR_RND_MODE				(0x00000080)

#define PVRVDA_MC_TYPE_SUB_PEL_MASK				(0x00000700)
#define PVRVDA_MC_TYPE_SUB_PEL_HALF				(0x00000000)
#define PVRVDA_MC_TYPE_SUB_PEL_QUART_MPEG		(0x00000100)
#define PVRVDA_MC_TYPE_SUB_PEL_QUART_WMV8		(0x00000700)
#define PVRVDA_MC_TYPE_SUB_PEL_QUART_WMV9		(0x00000300)
#define PVRVDA_MC_TYPE_SUB_PEL_QUART_H264		(0x00000400)
#define PVRVDA_MC_TYPE_SUB_PEL_EIGHTH_H264		(0x00000500)

/* Fetch Prediction A */
#define PVRVDA_FETCH_PRED_PREDX_MASK			(0x00003fff)
#define PVRVDA_FETCH_PRED_PREDX_SHIFT			(0)
#define PVRVDA_FETCH_PRED_PREDY_MASK			(0x0fffc000)
#define PVRVDA_FETCH_PRED_PREDY_SHIFT			(14)
#define PVRVDA_FETCH_PRED_SRC_SEL_MASK			(0x30000000)
#define PVRVDA_FETCH_PRED_SRC_SEL_REF1			(0x00000000)
#define PVRVDA_FETCH_PRED_SRC_SEL_REF2			(0x10000000)
#define PVRVDA_FETCH_PRED_SRC_SEL_OUT			(0x20000000)
#define PVRVDA_FETCH_PRED_SRC_SEL_SHIFT			(28)
#define PVRVDA_FETCH_PRED_FIRST_PRED			(0x40000000)

/* Prediction Target */
#define PVRVDA_PRED_TARGET_IP_FIELD_MODE		(0x00000001)
#define PVRVDA_PRED_TARGET_ACC_FIELD_MODE		(0x00000002)
#define PVRVDA_PRED_TARGET_ACC_FIELD_SLCT		(0x00000004)

#define PVRVDA_PRED_TARGET_ACC_Y_POS_MASK		(0x00000700)
#define PVRVDA_PRED_TARGET_ACC_Y_POS_0			(0x00000000)
#define PVRVDA_PRED_TARGET_ACC_Y_POS_2			(0x00000100)
#define PVRVDA_PRED_TARGET_ACC_Y_POS_4			(0x00000200)
#define PVRVDA_PRED_TARGET_ACC_Y_POS_6			(0x00000300)
#define PVRVDA_PRED_TARGET_ACC_Y_POS_8			(0x00000400)
#define PVRVDA_PRED_TARGET_ACC_Y_POS_10			(0x00000500)
#define PVRVDA_PRED_TARGET_ACC_Y_POS_12			(0x00000600)
#define PVRVDA_PRED_TARGET_ACC_Y_POS_14			(0x00000700)
#define PVRVDA_PRED_TARGET_ACC_X_POS_MASK		(0x00007000)
#define PVRVDA_PRED_TARGET_ACC_X_POS_0			(0x00000000)
#define PVRVDA_PRED_TARGET_ACC_X_POS_2			(0x00001000)
#define PVRVDA_PRED_TARGET_ACC_X_POS_4			(0x00002000)
#define PVRVDA_PRED_TARGET_ACC_X_POS_6			(0x00003000)
#define PVRVDA_PRED_TARGET_ACC_X_POS_8			(0x00004000)
#define PVRVDA_PRED_TARGET_ACC_X_POS_10			(0x00005000)
#define PVRVDA_PRED_TARGET_ACC_X_POS_12			(0x00006000)
#define PVRVDA_PRED_TARGET_ACC_X_POS_14			(0x00007000)
#define PVRVDA_PRED_TARGET_ACC_Y_POS_SHIFT		(7)
#define PVRVDA_PRED_TARGET_ACC_X_POS_SHIFT		(11)

/* ADD IDCT*/
#define PVRVDA_ADD_RESID_FIELD					(0x00000001)
#define PVRVDA_ADD_RESID_INTRA					(0x00000002)
#define PVRVDA_ADD_RESID_BLK_SELX_MASK			(0x0000000c)
#define PVRVDA_ADD_RESID_BLK_SELX_SHIFT			(2)
#define PVRVDA_ADD_RESID_BLK_SELY_MASK			(0x00000030)
#define PVRVDA_ADD_RESID_BLK_SELY_SHIFT			(4)

/* defines for simplicity in 8x8 mode */
#define PVRVDA_ADD_RESID_BLK_TOP_LEFT			(0x00000000)
#define PVRVDA_ADD_RESID_BLK_TOP_RGHT			(0x00000008)
#define PVRVDA_ADD_RESID_BLK_BOT_LEFT			(0x00000020)
#define PVRVDA_ADD_RESID_BLK_BOT_RGHT			(0x00000028)

#define PVRVDA_ADD_RESID_BLK_BOT_FIELD_LEFT		(0x00000010)
#define PVRVDA_ADD_RESID_BLK_BOT_FIELD_RGHT		(0x00000018)

#define PVRVDA_ADD_RESID_DCOFFSET				(0x00000080)
#define PVRVDA_RESID_BLK_SIZE_MASK				(0x00000300)
#define PVRVDA_RESID_BLK_SIZEX_4				(0x00000100)
#define PVRVDA_RESID_BLK_SIZEX_8				(0x00000000)
#define PVRVDA_RESID_BLK_SIZEY_4				(0x00000200)
#define PVRVDA_RESID_BLK_SIZEY_8				(0x00000000)

#define PVRVDA_RESID_MODE_MASK					(0x00000c00)
#define PVRVDA_RESID_MODE_COMPAT				(0x00000000)
#define PVRVDA_RESID_MODE_FULL_HW				(0x00000c00)
#define PVRVDA_RESID_MODE_BYPASS_IZZ			(0x00000800)
#define PVRVDA_RESID_MODE_BYPASS_IDCT			(0x00000400)
#define PVRVDA_RESID_ONLY_DC					(0x00001000)
#define PVRVDA_RESID_DC_VALUE_MASK				(0x003fe000)
#define PVRVDA_RESID_DC_VALUE_SHIFT				(13)

/* Image Write */
#define PVRVDA_IMAGE_WRITE_CACHE_RIGHT			(0x00000000)
#define PVRVDA_IMAGE_WRITE_CACHE_LEFT			(0x00000001)
#define PVRVDA_IMAGE_WRITE_CACHE_TOP			(0x00000002)
#define PVRVDA_IMAGE_WRITE_CACHE_BOTTOM			(0x00000003)
#define PVRVDA_IMAGE_WRITE_CACHE_MODE_MASK		(0x00000003)
#define PVRVDA_IMAGE_WRITE_CACHE_EN				(0x00000004)
#define PVRVDA_IMAGE_WRITE_X_MASK				(0x000007f8)
#define PVRVDA_IMAGE_WRITE_X_SHIFT				(0)
#define PVRVDA_IMAGE_WRITE_Y_MASK				(0x003ff800)
#define PVRVDA_IMAGE_WRITE_Y_SHIFT				(11)
#define PVRVDA_IMAGE_WRITE_FIELD				(0x00400000)
#define PVRVDA_IMAGE_WRITE_WIDTH_MASK			(0x01800000)
#define PVRVDA_IMAGE_WRITE_WIDTH_8				(0x00800000)
#define PVRVDA_IMAGE_WRITE_WIDTH_16				(0x01000000)
#define PVRVDA_IMAGE_WRITE_HGHT_MASK			(0x06000000)
#define PVRVDA_IMAGE_WRITE_HGHT_4				(0x00000000)
#define PVRVDA_IMAGE_WRITE_HGHT_8				(0x02000000)
#define PVRVDA_IMAGE_WRITE_HGHT_16				(0x04000000)

#define PVRVDA_INTRA_BLOCK_SIZE_MASK			(0x00000003)
#define PVRVDA_INTRA_BLOCK_SIZE_Y4				(0x00000000)
#define PVRVDA_INTRA_BLOCK_SIZE_Y16				(0x00000001)
#define PVRVDA_INTRA_BLOCK_SIZE_U8				(0x00000002)
#define PVRVDA_INTRA_BLOCK_SIZE_V8				(0x00000003)
#define PVRVDA_INTRA_MBADDR_X_MASK				(0x00001ffc)
#define PVRVDA_INTRA_MBADDR_X_SHIFT				(2)
#define PVRVDA_INTRA_MBADDR_Y_MASK				(0x00ffe000)
#define PVRVDA_INTRA_MBADDR_Y_SHIFT				(13)
#define PVRVDA_INTRA_FIELD_MODE					(0x01000000)

#define PVRVDA_INTRA_PRED_SUBBLOCK0_MASK		(0x0000000f)
#define PVRVDA_INTRA_PRED_SUBBLOCK1_MASK		(0x000000f0)
#define PVRVDA_INTRA_PRED_SUBBLOCK2_MASK		(0x00000f00)
#define PVRVDA_INTRA_PRED_SUBBLOCK3_MASK		(0x0000f000)
#define PVRVDA_INTRA_PRED_SUBBLOCK0_SHIFT		(0)
#define PVRVDA_INTRA_PRED_SUBBLOCK1_SHIFT		(4)
#define PVRVDA_INTRA_PRED_SUBBLOCK2_SHIFT		(8)
#define PVRVDA_INTRA_PRED_SUBBLOCK3_SHIFT		(12)
#define PVRVDA_INTRA_PRED_BLOCK_SELECT_MASK		(0x00030000)
#define PVRVDA_INTRA_PRED_BLOCK_SELECT_SHIFT	(16)
#define PVRVDA_INTRA_PRED_RESID_MASK			(0x003c0000)
#define PVRVDA_INTRA_PRED_RESID_SHIFT			(18)
#define PVRVDA_INTRA_PRED_RESID_0				(0x00040000)
#define PVRVDA_INTRA_PRED_RESID_1				(0x00080000)
#define PVRVDA_INTRA_PRED_RESID_2				(0x00100000)
#define PVRVDA_INTRA_PRED_RESID_3				(0x00200000)
#define PVRVDA_INTRA_PRED_HW_RESID				(0x00400000)

#define PVRVDA_INTRA_PRED_MODE_DC_NONE			(0x0)
#define PVRVDA_INTRA_PRED_MODE_DC_L				(0x1)
#define PVRVDA_INTRA_PRED_MODE_DC_U				(0x2)
#define PVRVDA_INTRA_PRED_MODE_DC_UL			(0x3)
#define PVRVDA_INTRA_PRED_VERTICAL				(0x4)
#define PVRVDA_INTRA_PRED_HORIZONTAL			(0x5)
#define PVRVDA_INTRA_PRED_DOWN_LEFT				(0x6)
#define PVRVDA_INTRA_PRED_DOWN_LEFT_UR			(0x7)
#define PVRVDA_INTRA_PRED_DOWN_RIGHT			(0x8)
#define PVRVDA_INTRA_PRED_VERTICAL_RIGHT		(0x9)
#define PVRVDA_INTRA_PRED_HORIZONTAL_DOWN		(0xa)
#define PVRVDA_INTRA_PRED_HORIZONTAL_UP			(0xb)
#define PVRVDA_INTRA_PRED_VERTICAL_LEFT			(0xc)
#define PVRVDA_INTRA_PRED_VERTICAL_LEFT_UR		(0xd)
#define PVRVDA_INTRA_PRED_PLANE					(0xe)

#define PVRVDA_INTRA_PRED_AVAILABLE_LEFT		(0x1)
#define PVRVDA_INTRA_PRED_AVAILABLE_UP			(0x2)
#define PVRVDA_INTRA_PRED_AVAILABLE_UP_RIGHT	(0x1)

/* Process H264 Residual */
#define PVRVDA_PROCESS_RES_QP_MASK				(0x0000003f)
#define PVRVDA_PROCESS_RES_QP_SHIFT				(20)
#define PVRVDA_PROCESS_RES_DC_CODED				(0x00010000)
#define PVRVDA_PROCESS_RES_CBP_MASK				(0x0000ffff)
#define PVRVDA_PROCESS_RES_CBP_SHIFT			(0)

#define PVRVDA_PROCESS_RES_MODE_INTRA16			(0x00000000)
#define PVRVDA_PROCESS_RES_MODE_INTER4			(0x00020000)
#define PVRVDA_PROCESS_RES_MODE_CHROMA8			(0x00040000)
#define PVRVDA_PROCESS_RES_MODE_NO_RES			(0x00060000)

/* H264 Residual Data Format */
#define PVRVDA_H264_RES_SCAN_ORDER_CHANGE		(0x00008000)
#define PVRVDA_H264_RES_SCAN_ORDER_ZZ			(0x00000000)
#define PVRVDA_H264_RES_SCAN_ORDER_RASTER		(0x00006000)
#define PVRVDA_H264_RES_COEF_IDX_SHIFT			(2)
#define PVRVDA_H264_RES_COEF_IDX_MASK			(0x1f)
#define PVRVDA_H264_RES_COEF_EOB				(0x2)
#define PVRVDA_H264_RES_COEF_EOD				(0x1)


/* Input Data Format **************************************************************/
#define PVRVDA_IZZ_EOB							(0x00000001)
#define PVRVDA_IZZ_MODE_CHANGE					(0x00008000)
#define PVRVDA_IZZ_SCAN_MASK					(0x00006000)
#define PVRVDA_IZZ_SCAN_ZIG_ZAG					(0x00000000)
#define PVRVDA_IZZ_SCAN_ALT_VERT				(0x00002000)
#define PVRVDA_IZZ_SCAN_ALT_HORIZ				(0x00004000)
#define PVRVDA_IZZ_SCAN_RASTER					(0x00006000)
#define PVRVDA_IZZ_COEFF_SHIFT					(16)
#define PVRVDA_IZZ_INDEX_SHIFT					(1)
#define PVRVDA_IZZ_INDEX_MASK					(0xfe)


/* Deblocking Commands ************************************************************/

#define PVRVDA_DBCMD_MASK						(0xf0000000)
#define PVRVDA_DBCMD_SET_MODE_0					(0x00000000)
#define PVRVDA_DBCMD_FILTER_0					(0x10000000)
#define PVRVDA_DBCMD_SYNC_0						(0x20000000)
#define PVRVDA_DBCMD_SET_MODE_1					(0x40000000)
#define PVRVDA_DBCMD_FILTER_1					(0x50000000)
#define PVRVDA_DBCMD_SYNC_1						(0x60000000)

#define PVRVDA_DB_MODE_MASK						(0x0e000000)
#define PVRVDA_DB_MODE_H264						(0x00000000)
#define PVRVDA_DB_MODE_MPEG4					(0x02000000)
#define PVRVDA_DB_H264_A_OFF_MASK				(0x0000001f)
#define PVRVDA_DB_H264_A_OFF_SHIFT				(0)
#define PVRVDA_DB_H264_B_OFF_MASK				(0x000003e0)
#define PVRVDA_DB_H264_B_OFF_SHIFT				(5)

#define PVRVDA_DB_FILT_MBA_X_MASK				(0x0000007f)
#define PVRVDA_DB_FILT_MBA_X_SHIFT				(0)
#define PVRVDA_DB_FILT_MBA_Y_MASK				(0x0003ff80)
#define PVRVDA_DB_FILT_MBA_Y_SHIFT				(7)
#define PVRVDA_DB_FILT_CC_MASK					(0x000c0000)
#define PVRVDA_DB_FILT_CC_Y						(0x00000000)
#define PVRVDA_DB_FILT_CC_U						(0x00040000)
#define PVRVDA_DB_FILT_CC_V						(0x00080000)
#define PVRVDA_DB_FILT_MB_COUNT_MASK			(0x07f00000)
#define PVRVDA_DB_FILT_MB_COUNT_SHIFT			(20)

#define PVRVDA_DB_FILT_QAV_MASK					(0xfc00)
#define PVRVDA_DB_FILT_QAV_SHIFT				(10)
#define PVRVDA_DB_FILT_OR_MASK					(0x0300)
#define PVRVDA_DB_FILT_OR_NORMAL				(0x0000)
#define PVRVDA_DB_FILT_OR_DISABLE				(0x0100)
#define PVRVDA_DB_FILT_ALL_STR_3				(0x0200)
#define PVRVDA_DB_FILT_ALL_STR_4				(0x0300)
#define PVRVDA_DB_FILT_STR_SHIFT				(2)
#define PVRVDA_DB_FILT_STR_MASK					(0x03)

#define PVRVDA_DB_SYNC_WRITEBACK				(0x00010000)
#define PVRVDA_DB_SYNC_VALUE_MASK				(0x0000ffff)


#endif /* _PVR_VDA_COMMAND_STREAM_H_ */
